<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>预约申请</title>

    <!-- styles here -->
    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../css/Public_CSS.css">
    <link rel="stylesheet" href="../css/mui.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>

<body>
    <div class="apply-page" id="app">
        <div class="banner-back">
            <span onclick="window.history.back()">
                <i>返回</i>
            </span>预约申请
        </div>
        <div class="scroll-y">
            <div v-if="recommend" class="form-group">
                <label>推荐人姓名</label>:
                <span class="imp">*</span>                
                <input type="text" v-model="requestData.rename" placeholder="请填写推荐人的姓名">
            </div>
            <div v-if="recommend" class="form-group">
                <label>推荐人电话</label>:
                <span class="imp">*</span>
                <input type="text" v-model="requestData.rephone" placeholder="请填写推荐人的手机号">
            </div>
            <div class="form-group">
                <label>姓名</label>:
                <span class="imp">*</span>
                <input type="text" v-model="requestData.username" placeholder="请填写您身份证上的姓名">
            </div>
            <div class="form-group">
                <label>手机号</label>:
                <span class="imp">*</span>
                <input type="text" v-model="requestData.phone" placeholder="请填写您的手机号">
            </div>
            <div class="form-group">
                <label>所在地址</label>:
                <input type="text" v-model="requestData.address" placeholder="请选择所在区县">
            </div>
            <div class="form-group">
                <label>申请银行</label>:
                <input type="text" v-model="requestData.bank" placeholder="请填写您申请的银行">
            </div>
            <div class="agreement">
                <i>&radic;</i>
                <input type="checkbox" v-model="agree1" onclick="toggleActived()">
                <a href="./authorization-agreement1.html">我接受 用户使用协议</a>
            </div>
            <div>
                <button onclick="sub()">提交</button>
            </div>
        </div>

    </div>

    <!-- scripts here -->
    <script type="text/javascript" src="../js/main.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/vue.min.js"></script>
    <script type="text/javascript" src="../../public/js/loan/mui.min.js"></script>
    <script>
        function sub(event) {
            var event = event || window.event;
            event.preventDefault(); // 兼容标准浏览器
            window.event.returnValue = false;
            vm.sumibt();
        }
        var vm = new Vue({
            el: "#app",
            data: {
                agree1: false,
                requestData: {},
                recommend: (function () {
                    if (/recommend/.test(window.location.href)) {
                        return window.location.href.split('?')[1].split('&').filter(function (a) {
                            return /recommend/.test(a);
                        })[0].split('=')[1] === 'true';
                    } else {
                        return false;
                    }
                })()
            },
            methods: {
                sumibt: function () {
                    if (!$("input[type='checkbox']").prop("checked")) {
                        mui.alert("请先阅读并同意协议");
                        return;
                    }
                    vm.requestData['appId'] = appId();
                    console.log("datga", JSON.stringify(vm.requestData))
                    $.ajax({
                        url: "/thmlfApi/avs/yb/appoCard",
                        type: "POST",
                        data: JSON.stringify(vm.requestData),
                        contentType: "application/json",
                        success: function (r) {
                            if (r.code == 200) {
                                mui.alert("预约申请提交成功\n请等候工作人员审批通知", null, null, function () {
                                    window.location.href =
                                        "/yb/html/credit-card.html?appId=" + appId();
                                });
                            } else
                                alert(r.message, ' ');
                        },
                        error: function (e) {
                            console.log("request error", e);
                            mui.alert("请求失败，请稍后重试");
                        }
                    });
                }
            }
        });
    </script>

</body>

</html>